#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int n, m;
vector<vector<int>> dp;
map<char, int> mp;
int main()
{
    mp['l'] = 4; mp['o'] = 3;
    mp['v'] = 2; mp['e'] = 1;
    int val = 0;

    n, m = 0;

    cin >> n >> m;

    vector<vector<char>> v;
    v.resize(n+1);
    for (int i = 0; i < n+1; i++) v[i].resize(m+1);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> v[i][j];

    dp.resize(n + 1);
    for (int i = 0; i < n + 1; i++) dp[i].resize(m + 1);
    if (mp.end() != mp.find(v[0][0]))
        dp[1][1] = mp[v[0][0]];
    else dp[1][1] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (mp.end() != mp.find(v[i][j]))
                val = mp[v[i][j]];
            else val = 0;
            dp[i][j] = max(dp[i - 1][j] ,dp[i][j - 1] ) +val;
        }
    }
    int ret = 0;
    for (int x : dp[n])
    {
        ret = max(ret, x);
    }
    cout << ret << endl;;

}